/*
* Copyright© 2018 Shanxi Lu'an Taihang Laihui Net Tech co.,LTD.
*/
package org.finegold.core.netty.server.modules;


import org.finegold.core.netty.core.session.Session;
import org.finegold.core.netty.core.session.SessionManager;
import org.finegold.core.netty.server.modules.login.cmd.ModuleId;
import org.finegold.core.netty.server.modules.login.entity.Login;

/**
 * Description:
 *
 * @author QinYueFeng
 * @since: 1.0
 * Create Date Time: 2018/10/19 11:45
 * Update Date Time:
 */
public class Common {


    /**
     * Description: 登录模块通知客户端
     * @param session 当前会话
     * @param cmd 命令号
     * @author QinYueFeng
     * Create Date Time: 2018/10/19 11:56
     * Update Date Time:
     */
    public static void LoginNotifyClient(Session session, Short cmd) {
        commonNotifyClient(session,ModuleId.LOGIN,cmd);
    }

    /**
     * Description: 通用通知客户端
     * @param session 当前会话
     * @param module 模块号
     * @param cmd 命令号
     * @author QinYueFeng
     * Create Date Time: 2018/10/19 11:48
     * Update Date Time:
     */
    private static void commonNotifyClient(Session session, short module, short cmd) {
        Object object = session.getAttachment();
        if (object != null) {
            Login login = (Login) object;
            // 给客户端回消息
            SessionManager.sendMessage(login.getUserId(), module, cmd, null);
        }
    }
}
